#ifndef __TM1637_DISPLAY_H
#define __TM1637_DISPLAY_H

#include <headfile.h>
#include <GPIO.h>

class TM1637
{
private:
    GPIO CLK;
    GPIO DIO;
    int delay_time;

    void start();
    void stop();
    void send_8b(uint8_t);
    void send_cmd(uint8_t);
    void send_data(uint8_t, uint8_t);

public:
    TM1637(Pin_enum dio, Pin_enum clk, int speed = 100)
    {
        CLK = GPIO(clk, OUT_PP);
        DIO = GPIO(dio, OUT_OD);

        CLK.write(1);
        DIO.write(1);

        delay_time = 1000000 / (speed * 1000);

        send_cmd(0x44);
        send_data(0xc0, 0x3f);
        send_data(0xc1, 0x3f);
        send_data(0xc2, 0x3f);
        send_data(0xc3, 0x3f);
        send_cmd(0x8a);
    };
    void show_num(int);
    void test();
};

#endif
